﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessLayer.Model.Services;
using System.Web.Security;
using BusinessLayer;
using BusinessLayer.Model.Services.Abstract;
using BusinessLayer.Model.Services.Concrete;
using System.IO;
using BusinessLayer.Model.Repositories.Abstract;

using BusinessLayer.Model.Entities;
using DataAccess.Services.Abstract;

namespace intecnologia.Admin
{
    public partial class Default : System.Web.UI.Page
    {
        ISessionService _sessionService = new SessionService();
        ILoginService _loginService = new LoginService();

        protected void Page_Load(object sender, EventArgs e)
        {
            var u = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath;
        }

        protected bool UserLoggedIn()
        {
            return _sessionService.UserLoggedIn;
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            LoginUser(tbUsername.Text, tbPassword.Text);
        }

        private void LoginUser(string user, string pass)
        {  
            if (_loginService.LoginUser(user, pass))
                Response.Redirect("~/Admin/Default.aspx");

            else
                lblLoginError.Visible = true;

        }
    }
}
